import http from '@/utils/http'

const BASE_URL = '/system/storage'

export interface StorageResp {
  id: string
  name: string
  code: string
  type: string
  accessKey: string
  secretKey: string
  endpoint: string
  bucketName: string
  domain: string
  description: string
  default: string
  status: number
  sort: string
}

export interface StorageDetailResp extends StorageResp {
}

export interface StorageQuery extends SortQuery {
  keyword?: string
  status?: number
}

export interface StoragePageQuery extends StorageQuery, PageQuery {

}

/** @desc 查询存储配置列表 */
export function getList(query: StorageQuery) {
  return http.get<StorageResp[]>(`${BASE_URL}/list`, query)
}

/** @desc 查询存储配置详情 */
export function getDetail(id: string) {
  return http.get<StorageDetailResp>(`${BASE_URL}/detail/${id}`)
}

/** @desc 创建存储配置 */
export function create(data: any) {
  return http.post(`${BASE_URL}/create`, data)
}

/** @desc 修改存储配置 */
export function update(data: any, id: string) {
  return http.post(`${BASE_URL}/update/${id}`, data)
}

/** @desc 删除存储配置 */
export function remove(id: string) {
  return http.post(`${BASE_URL}/delete/${id}`)
}
